﻿using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace MS.TravelJourney.Final.Core
{
    /// <summary>
    /// 工具类，可以针对WP手机进行一些全局设置
    /// </summary>
    public class Util
    {
        public void SaveDataSettings(string data)
        {
            var localSettings = IsolatedStorageSettings.ApplicationSettings;
            localSettings["background"] = data;
        }

        public string LoadDataSettings()
        {
            var localSettings = IsolatedStorageSettings.ApplicationSettings;
            var result = localSettings.Where(a => a.Key == "background");
            if (result.Any())
            {
                var color = localSettings["background"].ToString();
                return color;
            }
            return "";
        }

        public void ModifyBackgroundStyle(string color)
        {
            var solid = App.Current.Resources["BackgroundColor"] as SolidColorBrush;
            switch (color)
            {
                case "青绿":
                    solid.Color = new Color() { A = 255, R = 57, G = 197, B = 126 };
                    break;
                case "红色":
                    solid.Color = Colors.Red;
                    break;
                case "蓝色":
                    solid.Color = Colors.Blue;
                    break;
                case "粉红":
                    solid.Color = new Color() { A = 255, R = 244, G = 114, B = 208 };
                    break;
                case "绿色":
                    solid.Color = Colors.Green;
                    break;
                case "橘黄":
                    solid.Color = Colors.Orange;
                    break;
                default:
                    break;
            }
        }
    }
}
